@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        售后管理
        <small>退货商品列表</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/admin"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li ><a href="/admin/refund">售后管理</a></li>
        <li class="active">退货商品列表</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-xs-12">


            <div class="box box-primary ">
                <div class="box-body table-responsive">

                    {!! Form::model(@$refundGoods,array('route' => 'admin.refund.index','method' => 'get','class'=>'form-search form-inline pull-right')) !!}

                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::text('order_sn',$search['order_sn'],['class'=>'form-control','placeholder'=>'订单编号'])!!}
                    </div>

                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::text('refund_sn',$search['refund_sn'],['class'=>'form-control','placeholder'=>'服务单号'])!!}
                    </div>

                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::text('goods_sn',$search['goods_sn'],['class'=>'form-control','placeholder'=>'商品货号'])!!}
                    </div>
                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::select('refund_status',$refundStatusArr,@$_GET['refund_status'],['class'=>'form-control','placeholder'=>'售后状态'])!!}

                    </div>
                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::text('real_name',$search['real_name'],['class'=>'form-control','placeholder'=>'退货人姓名'])!!}
                    </div>
                    <div class="form-group" style="margin-right: 15px;">
                        {!! Form::text('phone',$search['phone'],['class'=>'form-control','placeholder'=>'电话'])!!}
                    </div>

                            <button type="submit" class="btn btn-primary ">搜索</button>
                            <button type="button" onclick="window.location.href='/admin/refund'" class="btn btn-default">重置</button>

                    {!! Form::close() !!}


                </div>

            </div><!-- end .box box-primary -->


            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">商品列表</h3>
                </div>
                <!-- /.box-header -->

                <div class="box-body table-responsive no-padding">


                    <table class="table table-hover" style="min-width: 1280px;">
                        <tr>
                            <th style="width: 50px">ID</th>
                            <th style="width: 80px">服务编号</th>
                            <th style="width: 80px">订单编号</th>
                            <th style="width: 80px">商品id</th>
                            <th style="width: 50px">数量</th>
                            <th style="width: 100px">状态</th>
                            <th style="width: 150px">用户名</th>
                            <th style="width: 50px">电话</th>
                            <th style="width: 50px">单价</th>
                            <th style="width: 50px">优惠券抵消的金额</th>
                            <th style="width: 50px">总价</th>
                            <th style="">原因</th>
                            {{--<th style="">备注</th>--}}
                            <th style="width: 160px;">操作</th>
                        </tr>

                        @foreach ($refundGoods as $item)
                        <tr>
                            <td>{{$item->refund_id}}</td>
                            <td>{{$item->refund_sn}}</td>
                            <td>{{$item->order_sn}}</td>
                            <td>{{$item->goods_id}}</td>
                            <td>{{$item->number}}</td>
                            <td>

                                <?php
                                    switch($item->refund_status){
                                        case 1:
                                            echo '<span class="badge btn-warning ">待确认</span>';
                                            break;
                                        case 2:
                                            echo '<span class="badge btn-success">受理中</span>';
                                            break;
                                        case 3:
                                            echo '<span class="badge btn-info">处理完毕</span>';
                                            break;
                                        case 4:
                                            echo '<span class="badge btn-danger">不予受理</span>';
                                            break;
                                        case 5:
                                            echo '<span class="badge btn-primary">已取消</span>';
                                            break;
                                        default:
                                            echo '<span class="badge btn-success">状态有误</span>';
                                            break;
                                    }
                                ?>

                            </td>
                            <td>{{$item->real_name}}</td>
                            <td>{{$item->phone}}</td>
                            <td>
                                @if($item->goods_real_price > 0)
                                    {{$item->goods_real_price}}
                                @else
                                    {{$item->shop_price}}
                                @endif
                            </td>
                            <td>{{$item->coupon_price_offset}}</td>
                            <td>
                                @if($item->goods_real_price > 0)
                                    <?php echo sprintf("%.2f",substr(sprintf("%.3f", $item->goods_real_price*$item->number - $item->coupon_price_offset), 0, -1)); ?>
                                @else
                                    <?php echo sprintf("%.2f",substr(sprintf("%.3f", $item->shop_price*$item->number - $item->coupon_price_offset), 0, -1)); ?>
                                @endif
                            </td>
                            <td>{{$item->reason}}</td>
                            {{--<td>{{$item->remark}}</td>--}}
                            <td>
                                @if($item->refund_status==1)
                                    <button type="button" class="btn  btn-success btn-xs"  data-toggle="modal" data-target="#modal{{trim($item->refund_sn)}}yes"> 予以受理</button>
                                    <button type="button" class="btn  btn-danger btn-xs"  data-toggle="modal" data-target="#modal{{trim($item->refund_sn)}}no"> 不予受理</button>

                                    <div id="modal{{trim($item->refund_sn)}}yes" class="modal fade">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title">操作确认:</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>确认受理吗?</p>
                                                </div>
                                                <div class="modal-footer">

                                                    {!! Form::open(['route' => ['admin.refund.update', $item->refund_sn],'name'=>$item->refund_sn, 'method'=>'PUT']) !!}

                                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

                                                    <input type="hidden" name="pre_url" value="<?php if(@$_SERVER['HTTP_REFERER']==''){ ?>{{route('admin.goods.index')}}<?php }else{echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];}?>"/>
                                                    {!! Form::hidden('operation', 'yes') !!}

                                                    {!! Form::submit('确认',array('class' => 'btn btn-danger')) !!}

                                                    {!!Form::close()   !!}
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->

                                    <div id="modal{{trim($item->refund_sn)}}no" class="modal fade">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title">操作确认:</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>确认不予受理吗?</p>
                                                </div>
                                                <div class="modal-footer">

                                                    {!! Form::open(['route' => ['admin.refund.update', $item->refund_sn],'name'=>$item->refund_sn, 'method'=>'PUT']) !!}

                                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

                                                    <input type="hidden" name="pre_url" value="<?php if(@$_SERVER['HTTP_REFERER']==''){ ?>{{route('admin.goods.index')}}<?php }else{echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];}?>"/>
                                                    {!! Form::hidden('operation', 'no') !!}


                                                    {!! Form::submit('确认',array('class' => 'btn btn-danger')) !!}


                                                    {!!Form::close()   !!}
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->
                                @endif()

                                @if($item->refund_status==2)
                                        <button type="button" class="btn  btn-info btn-xs"  data-toggle="modal" data-target="#modal{{trim($item->refund_sn)}}ok"> 处理完毕</button>

                                        <div id="modal{{trim($item->refund_sn)}}ok" class="modal fade">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                        <h4 class="modal-title">操作确认:</h4>
                                                    </div>
                                                    <div class="modal-body" style="text-align:center;">
                                                        <p>确认完成吗?</p>
                                                    </div>
                                                    <div class="modal-footer">

                                                        {!! Form::open(['route' => ['admin.refund.update', $item->refund_sn],'name'=>$item->refund_sn, 'method'=>'PUT']) !!}

                                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

                                                        <input type="hidden" name="pre_url" value="<?php if(@$_SERVER['HTTP_REFERER']==''){ ?>{{route('admin.goods.index')}}<?php }else{echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];}?>"/>
                                                        {!! Form::hidden('operation', 'ok') !!}

                                                        {!! Form::submit('确认',array('class' => 'btn btn-danger')) !!}

                                                        {!!Form::close()   !!}
                                                    </div>
                                                </div><!-- /.modal-content -->
                                            </div><!-- /.modal-dialog -->
                                        </div><!-- /.modal -->
                                @endif()
                            </td>
                        </tr>
                        @endforeach

                    </table>

                </div>
                <!-- /.box-body -->

                <div class="box-footer">
                    <!-- 分页 -->
                    <div class="pull-right no-margin-pager">
                        {!! $refundGoods->appends(['order_sn' => $search['order_sn'], 'refund_sn' => $search['refund_sn'], 'goods_sn' => $search['goods_sn'], 'refund_status' => $search['refund_status'], 'real_name' => $search['real_name'], 'phone' => $search['phone']])->render() !!}
                    </div>

                </div>

            </div>
            <!-- /.box -->

        </div>
    </div>


</div>
</section>
<!-- /.content -->

@endsection